Slide 1: Introduction to Non-Financial Applications of Blockchain


Slide 2: Supply Chain Management

  contract SupplyChain {
    address public admin;
    mapping(address => bool) public authorizedEntities;
    mapping(address => uint) public roles; // 0: ADMIN, 1: AUTHORIZER, 2: MANUFACTURER

    struct Product {
        string name;
        address manufacturer;
        bool isVerified;
    }

    mapping(uint => Product) public products;

    constructor() {
        admin = msg.sender;
        roles[msg.sender] = 0; // Assign admin role to deployer
    }

    modifier onlyAdmin() {
        require(roles[msg.sender] == 0, "Only admin can perform this action");
        _;
    }

    modifier onlyAuthorized() {
        require(authorizedEntities[msg.sender] || roles[msg.sender] == 0, "Not authorized");
        _;
    }

    modifier onlyManufacturer(uint productId) {
        require(msg.sender == products[productId].manufacturer || roles[msg.sender] == 0, "Only manufacturer can verify");
        _;
    }

    function authorizeEntity(address entity, uint role) public onlyAdmin {
        authorizedEntities[entity] = true;
        roles[entity] = role;
    }

    function addProduct(uint productId, string memory name) public onlyAuthorized {
        products[productId] = Product(name, msg.sender, false);
    }

    function verifyProduct(uint productId) public onlyManufacturer(productId) {
        products[productId].isVerified = true;
    }
}

Slide 3: Healthcare Data Management


Slide 4: Government Applications


Slide 5: Education and Credential Verification


Slide 6: Media and Entertainment


Slide 7: Social Impact Tracking and Charity Donations


Slide 8: Land Registry and Public Records

Decentralized Marketplaces:** Considerations for secure and fair payment management are crucial to avoid fraud in ownership transfers.


Slide 9: Security in Lending Protocols - Preventing Flash Loan Attacks


** Slide 10 : Secure Voting **

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Voting {
    struct Voter {
        bytes32 commitment; 
        bool revealed;      
        uint8 vote;         
    }

    address public owner;
    uint256 public commitEndTime;
    uint256 public revealEndTime;
    mapping(address => Voter) public voters;
    uint256 public yesVotes;
    uint256 public noVotes;

    event VoteCommitted(address indexed voter);
    event VoteRevealed(address indexed voter, uint8 vote);

    modifier onlyDuringCommitPhase() {
        require(block.timestamp < commitEndTime, "Commit phase has ended");
        _;
    }

    modifier onlyDuringRevealPhase() {
        require(block.timestamp >= commitEndTime, "Reveal phase not started");
        require(block.timestamp < revealEndTime, "Reveal phase has ended");
        _;
    }

    constructor(uint256 _commitDuration, uint256 _revealDuration) {
        owner = msg.sender;
        commitEndTime = block.timestamp + _commitDuration;
        revealEndTime = commitEndTime + _revealDuration;
    }

    function commitVote(bytes32 _commitment) external onlyDuringCommitPhase {
        require(voters[msg.sender].commitment == bytes32(0), "Already committed");

        voters[msg.sender].commitment = _commitment;
        emit VoteCommitted(msg.sender);
    }

    function revealVote(uint8 _vote, string calldata _salt) external onlyDuringRevealPhase {
        Voter storage voter = voters[msg.sender];
        require(voter.commitment != bytes32(0), "No commitment found");
        require(!voter.revealed, "Already revealed");
        require(_vote == 1 || _vote == 0, "Vote must be 0 or 1");

        bytes32 commitmentCheck = keccak256(abi.encodePacked(_vote, _salt));
        require(commitmentCheck == voter.commitment, "Commitment does not match");

        voter.vote = _vote;
        voter.revealed = true;

        if (_vote == 1) {
            yesVotes++;
        } else {
            noVotes++;
        }

        emit VoteRevealed(msg.sender, _vote);
    }

    function getVotingResult() external view returns (string memory) {
        require(block.timestamp >= revealEndTime, "Reveal phase not finished");
        
        if (yesVotes > noVotes) {
            return "Yes wins";
        } else if (noVotes > yesVotes) {
            return "No wins";
        } else {
            return "Tie";
        }
    }

    function generateCommitment(uint8 _vote, string calldata _salt) external pure returns (bytes32) {
        return keccak256(abi.encodePacked(_vote, _salt));
    }
}